package org.taobao.ibatiside.ui.action;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.ui.navigator.CommonViewer;

public abstract class AbstractViewerAction extends Action implements
		ISelectionChangedListener {
	protected SelectionChangedEvent event;
	protected CommonViewer viewer;
	public void initialize(CommonViewer viewer) {
		this.viewer = viewer;
	}
	@Override
	public void selectionChanged(SelectionChangedEvent event) {
		this.event = event;
	}
	protected Object getSelectObject() {
		return ((IStructuredSelection) event.getSelection()).getFirstElement();
	}
}
